{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>{if !empty($data)}修改{else}添加{/if}道具</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="add_cate" id="add_prop" method="post" action="">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名&nbsp;&nbsp;称：</label>
                            <div class="input-group col-sm-4">
                                <input id="name" type="text" class="form-control" name="name" value="{$data.name|default=''}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图&nbsp;&nbsp;片：</label>
                            <div class="controls uploadrow2" data-max="1" title="点击修改图片" rel="p_cover">
                                    <input type="hidden" name="logo" id="cover_id_p_cover" value="{$data.logo|default=''}" data-callback="uploadImgCallback" value=""/>
                                    <div class="upload-img-box" rel="img"  {if empty($data['logo'])} style="display:none" {/if} >
                                      <div class="upload-pre-item2">
                                            <img width="100" height="100" src="{$data.logo|default=''}"/>
                             </div>
                                        <em class="edit_img_icon">&nbsp;</em>
                                    </div>
                              </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">说&nbsp;&nbsp;明：</label>
                            <div class="input-group col-sm-4">
                                <input id="orderby" type="text" class="form-control" name="remark" value="{$data.remark|default=''}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                                <label class="col-sm-3 control-label">类&nbsp;&nbsp;型：</label>
                                    <div class="input-group col-sm-4">
                                        <select class="form-control" name="type">
                                            <option  value="">请选择</option>
                                            <option {if condition="@$data['type'] eq 1"}selected{/if} value="1">经验</option>
                                            <option {if condition="@$data['type'] eq 2"}selected{/if} value="2">加分</option>
                                            <option {if condition="@$data['type'] eq 3"}selected{/if} value="3">加金币</option>
                                            <option {if condition="@$data['type'] eq 4"}selected{/if} value="4">知识书</option>
                                        </select>
                                    </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                                <label class="col-sm-3 control-label">动作类型：</label>
                                    <div class="input-group col-sm-4">
                                        <select class="form-control" name="action_type">
                                            <option value="">请选择</option>
                                            <option {if condition="@$data['action_type'] eq 1"}selected{/if} value="1">场</option>
                                            <option {if condition="@$data['action_type'] eq 2"}selected{/if} value="2">时</option>
                                        </select>
                                    </div>
                        </div>
                        
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类型奖励值：</label>
                            <div class="input-group col-sm-4">
                                <input id="orderby" type="text" class="form-control" name="reward_val" value="{$data.reward_val|default=''}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">奖励比例（时，场类型加成比例）：</label>
                            <div class="input-group col-sm-4">
                                <input id="orderby" type="text" class="form-control" name="reward_scale" value="{$data.reward_scale|default=''}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">

                                <label class="col-sm-3 control-label">科目&nbsp;&nbsp;id：</label>
                                <div class="input-group col-sm-4">                         
                                    <select name="subject_id" id="subject_id" class="form-control">
                                            <option value="">请选择</option>
                                        {foreach name="list" item="v"}
                                            <option value="{$v.id}" style="margin-left:55px;"{if condition="$v.parent_id eq 0"}disabled="disabled"{/if}{if condition="@$data['subject_id'] eq $v.id"}selected{/if}>{$v.lefthtml}{$v.name}</option>
                                        {/foreach}                                  
                                    </select>                                    
                                </div>
                            </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">

$(function(){
    //初始化上传图片插件
    initUploadImg();
});

function uploadImgCallback(name,id,src){

    $('#cover_id_p_cover').val(src);
}

</script>

<script type="text/javascript">

    $(function(){
        $('#add_prop').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });
        
        function checkForm(){
            if( '' == $.trim($('#name').val())){
                layer.msg('请输入名称',{icon:2,time:1500,shade: 0.1}, function(index){
                layer.close(index);
                });
                return false;
            }

        }

        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('prop/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
    });
</script>
</body>
</html>